package com.ruoyi.web.controller.approve;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.domain.ExaExpense;
import com.ruoyi.service.IExaExpenseService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2020-07-01
 */
@Controller
@RequestMapping("/ruoyi/expenses")
public class MoneyExpenseController extends BaseController
{
    private String prefix = "ruoyi/expense";

    @Autowired
    private IExaExpenseService exaExpenseService;

    @RequiresPermissions("ruoyi:expenses:view")
    @GetMapping()
    public String expense()
    {
        return prefix + "/expenseMoney";
    }

    /**
     * 查询【请填写功能名称】列表
     */
    @RequiresPermissions("ruoyi:expenses:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ExaExpense exaExpense)
    {

        List<ExaExpense> list = exaExpenseService.selectExaExpenseList(exaExpense);
//        list.removeIf(exaExpense1 -> exaExpense1.geteStatus()==0);
//        list.removeIf(exaExpense1 -> exaExpense1.geteStatus()==1);
//        list.removeIf(exaExpense1 -> exaExpense1.geteStatus()==2);
//        list.removeIf(exaExpense1 -> exaExpense1.geteStatus()==3);
//        list.removeIf(exaExpense1 -> exaExpense1.geteStatus()==4);
        startPage();
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @RequiresPermissions("ruoyi:expenses:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ExaExpense exaExpense)
    {
        List<ExaExpense> list = exaExpenseService.selectExaExpenseList(exaExpense);
        ExcelUtil<ExaExpense> util = new ExcelUtil<ExaExpense>(ExaExpense.class);
        return util.exportExcel(list, "expense");
    }

}
